unit uniGer;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    procedure FormShow(Sender: TObject);
  private
    function criptografia(texto: String; acao:Char):String;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.criptografia(texto: String; acao: Char): String;
var     senha : string[255];
        caracter : array[0..255] of Byte absolute senha;
        i:Integer;
begin
        //seta string
        senha:=texto;

        //SE CRIPTOGRAFA
        if (acao='C') then
        begin
                for i:=1 to Ord(senha[0]) do
                        caracter[i] := 23 XOr caracter[i];
        end
        //SE DECRIPTOGRAFA
        else if (acao='D') then
        begin
                for i:=1 to Length(senha) do
                        senha[i] := Char(23 Xor Ord(caracter[i]));
        end;

        //retorna
        Result := senha
end;

procedure TForm1.FormShow(Sender: TObject);
VAR Data, YYYY, MM, DD, sSenha : String;
begin
  //Quebra a data, precisa ta no formada DD/MM/YYYY
  Data := DateToStr(Date);
  DD := Copy(Data,0,2);
  MM := Copy(Data,4,2);
  YYYY := Copy(Data,7,4);

  sSenha := 'R'+DD+MM+YYYY+'L';
  Edit1.Text := criptografia(sSenha,'C');
end;

end.
